#region Using

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using EstateNuke.Report.EstateNukeCoreDBDataSetTableAdapters;
using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Forms;
using Microsoft.Reporting.WebForms;

#endregion

namespace EstateNuke.Report
{
    public partial class FinancialSummaryReportControl : UserControl
    {
        private DateTime DateFrom;
        private DateTime DateTo;
        private int ProjectId;

        public FinancialSummaryReportControl(DateTime datetimeFrom, DateTime datetimeTo, int projectId)
        {
            InitializeComponent();
            DateFrom = datetimeFrom;
            DateTo = datetimeTo;
            ProjectId = projectId;
        }

        private void reportViewer1_HostedPageLoad(object sender, Gizmox.WebGUI.Forms.Hosts.AspPageEventArgs e)
        {
            this.reportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
            reportViewer1.LocalReport.ReportPath = "../EstateNuke.Report/Report/FinancialSummaryReport.rdlc";
            this.reportViewer1.LocalReport.DataSources.Clear();

            EstateNukeCoreDBDataSet source = new EstateNukeCoreDBDataSet();

            FinancialContractSummaryReportTableAdapter adapterLease = new FinancialContractSummaryReportTableAdapter();
            adapterLease.Fill(source.FinancialContractSummaryReport, DateFrom, DateTo, ProjectId);

            FinancialLeaseContractSummaryReportTableAdapter adapterCustomerCommunication = new FinancialLeaseContractSummaryReportTableAdapter();
            adapterCustomerCommunication.Fill(source.FinancialLeaseContractSummaryReport, DateFrom, DateTo, ProjectId);

            this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FinancialContractSummaryDataSet", source.FinancialContractSummaryReport.Copy()));
            this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FinancialLeaseContractSummaryDataSet", source.FinancialLeaseContractSummaryReport.Copy()));

            this.reportViewer1.LocalReport.Refresh();
        }
    }
}